package Game;
import java.util.Stack;

/**
 * Creates a Wave of Enemy objects.
 * @author Jonathan Pellby
 *
 */
public class Wave {

	private Stack<Enemy> spawns;
	
	/**
	 * Constructor for Wave objects
	 */
	public Wave(){
		spawns = new Stack<Enemy>();
	}
	
	
	/**
	 * Add units to the Wave.
	 * ENUM?
	 * @param enemy the enemy to be added to the wave
	 */
	public void addUnit(Enemy enemy){
		spawns.add(enemy);
	}
	
	/**
	 * Add many different kind of enemies to the Wave.
	 * The enemies will be added alternatively, that is
	 * each type of enemy will be added one time each before
	 * adding more. Multiple enemies of the same type is possible.
	 * @param enemies an array with different kind of units
	 * 		  to be added. 
	 * @param multiple the multiple of enemies of each type to be added.
	 */
	public void addDifferentUnits(Enemy[] enemies, int multiple){
		int size = enemies.length; 
		for(int i = 0; i < multiple; i++){
			int count = 0;
			while(count < size){
				spawns.add(enemies[count]);
				count++;
			}
		}
	}
	
	/**
	 * Returns <code>true</code> if there are 
	 * enemies left to spawn
	 * @return <code>true</code> if there are enemies left to
	 * 		   spawn else false.
	 */
	public boolean hasNextSpawn(){
		return !(spawns.isEmpty());
	}
	
	/**
	 * Returns the next unit to be spawned
	 * @return the next unit to be spawned
	 */
	public Enemy nextSpawn(){
		return spawns.pop();
	}
	
	/**
	 * Returns the number of units left to spawn
	 * @return the number of units left to spawn
	 */
	public int leftToSpawn(){
		return spawns.size();
	}
}
